define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Purchase_distributor, $window, $timeout, GoPage, $ionicSlideBoxDelegate) {
		//一级导航--切换
		$scope.selectIndex = 0;
		$scope.slideChanged = function(index) {
			$scope.selectIndex = index;
		};
		$scope.activeSlide = function(index) {
			$scope.selectIndex = index;
			$ionicSlideBoxDelegate.$getByHandle('main-handle').slide(index);
		};
		
		
		//统计
		$scope.onshow_statistics = function(id){
			GoPage.go_states("statistics_distributor",{id:id});
		}
		//参加
		$scope.onshow_grabseckill = function(id){
			GoPage.go_states("grabseckill",{id:id});
		}
		
		$scope.isLoad = false; //可以加载
		//画面加载
		$scope.$on('$ionicView.afterEnter', function() {
			//动态设置高度
			var all = $window.innerHeight;
			//计算滚动条
			$scope.myObj = {
				"height": all - 44 + "px"
			};
		}, false);
		//下拉刷新 判断哪个模块进行刷新
		$scope.doRefresh = function() {
			$timeout(function() {
				$scope.$broadcast('scroll.refreshComplete');
			}, 1000);
		};
		//加载更多
		$scope.doRefreshMore = function() {
			$timeout(function() {
				$scope.$broadcast('scroll.infiniteScrollComplete');
			}, 1000);
		};
		$scope.init_data = function(){
			Purchase_distributor.get_list(3,function(data){
				$scope.datas = data;
			})
		}
		$scope.init_data();
	}

	controller.$inject = ['$scope', 'Purchase_distributor', '$window', '$timeout','GoPage', '$ionicSlideBoxDelegate'];
	
	return app.registerController("purchase_distributorctrl",controller);
});